package com.xc.tjise.TJISE.day10;

import com.xc.tjise.TJISE.day09.DB;
import org.apache.commons.dbcp.BasicDataSource;
import java.sql.Connection;
import java.sql.SQLException;

//数据库连接池 池化
public class DBCPDatasource {

    private static BasicDataSource basicDataSource = new BasicDataSource();

    static {
        basicDataSource.setUrl(DB.URL);
        basicDataSource.setUsername(DB.USERNAME);
        basicDataSource.setPassword(DB.PASSWORD);
    }
     public  static Connection getconnection(){
        try {
            return basicDataSource.getConnection();
        }catch (SQLException e){
            throw  new RuntimeException();
        }
     }
}
